<?php
	
	/* Cette classe permet de faciliter la génération des pages du site
	 * la méthode statique displayPageHeader prend en paramètres un array
	 * de chaines de caractères du type ("Titre onglet 1", "Lien Onglet 1",
	 * "Titre onglet 2", "Lien onglet 2" etc...), la chaine de caractere
	 * de l'onglet actif (un des titres du premier array), et un boolean
	 * pour activer ou non l'arborescence
	 */
	
	include_once("../../php/inc/defines.php");
	
	error_reporting(E_ALL);
	ini_set('display_errors', true);
	
	class layout {
		
		public static function displayPageHeader($tabsArray, $activeTab, $displayTree) {
			echo "<!DOCTYPE html>";
			echo "<html>";
			echo "<head>";
			echo "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\">"; /*fix pour les onglets sous IE8*/
			echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">";
			echo "<title>Intranet de gestion des notes ".VERSION."</title>";
			if($displayTree) {
				echo "<script type=\"text/javascript\" src=\"../../js/jquery.js\"></script>";
				echo "<script type=\"text/javascript\" src=\"../../js/jquery.jstree.js\"></script>";
				echo "<script type=\"text/javascript\" src=\"../../js/jquery.cook.js\"></script>";
				echo "<script type=\"text/javascript\">";
				echo "$(function() {";
				echo "$(\"#treeViewDiv\").jstree({ \"themes\":{\"theme\":\"classic\", \"dots\":false},";
				echo "\"plugins\" : [ \"themes\", \"html_data\", \"cookies\" ]";
				echo "})";
				echo "});";
				echo "</script>";
			}
			echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../css/styles.css\">";
			echo "</head>";
			echo "<body>";
			echo "<div class=\"header\">";
			echo "<div class=\"logo\">";
			echo "<img src=\"../../images/logo.png\" alt=\"Universit&eacute; du Maine\">";
			echo "</div>";
			echo "<div class=\"topMenuBar\">";
			echo "<div class=\"menuMessage\">";
			echo "Connect&eacute; en tant que ".$_SESSION["login"]." &ndash; <a class=\"logout\" href=\"../../php/dologout.php\">d&eacute;connexion</a>";
			echo "</div>";
			echo "</div>";
			echo "<div class=\"bottomMenuBar\">";
			for($i = 0; $i < count($tabsArray); $i+=2) {
				if($tabsArray[$i] == $activeTab)
					echo "<div class=\"menuTab active\">".$tabsArray[$i]."</div>";
				else
					echo "<div class=\"menuTab\"><a class=\"tabTitle\" href=\"".$tabsArray[$i + 1]."\">".$tabsArray[$i]."</a></div>";
			}
			echo "</div>";
			echo "</div>";
		}
		
		public static function displayPageFooter() {
			echo "</body>";
			echo "</html>";
		}
		
	}
?>
